home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 1.7 KB | 58 lines |
- /**
- * Apple Worldwide Developer Technical Support
- *
- * Sample showing how to send and receive AppleEvents using JDirect 2.
- *
- * File: ErrorHandler.java
- *
- * This class contains OSerr handling code.
- * @see NativeException
- *
- * @author Levi Brown
- * @author Apple Computer, Inc.
- *
- * Copyright ©1999 Apple Computer, Inc.
- * All rights reserved.
- *
- * @version 1.0
- * 4/15/1999 Shipped as 'AppleEvent Send and Receive' sample.
- *
- * You may incorporate this sample code into your applications without
- * restriction, though the sample code has been provided "AS IS" and the
- * responsibility for its operation is 100% yours. However, what you are
- * not permitted to do is to redistribute the source as "Apple Sample
- * Code" after having made changes. If you're going to re-distribute the
- * source, we require that you make it clear in the source that the code
- * was descended from Apple Sample Code, but that you've made changes.
- */
- public class ErrorHandler implements TypesConstants
- {
- /**
- * Checks to make sure no error has occured.
- * If the err parameter does not equal noErr, an exception will
- * be thrown containing a message.
- * @param err the OSError retured by some toolbox call.
- * @param errorText the message to use if an error has occured.
- * @exception NativeException if err is not equal to noErr
- * @see NativeException
- */
- public static void checkError(short err, String errorText) throws NativeException
- {
- if (err != noErr)
- {
- StringBuffer buffer = new StringBuffer();
- if (errorText != null)
- {
- buffer.append(errorText);
- buffer.append(": ");
- }
- else
- {
- buffer.append("Error ");
- }
- buffer.append(err);
-
- throw new NativeException(buffer.toString(), err);
- }
- }
- }